import React from 'react'; 
import {connect} from "react-redux";
import {getList,getList2} from '../action';
import {Link} from "react-router";
import LazyLoad from 'react-lazy-load'; 

var TestView0=React.createClass({
	componentWillMount:function(){
		this.props.dispatch(getList());
	},
	initLayout:function(){ 
		//每20条作为一个楼层，其他楼层懒加载
		var items=[];
		var lists=[];
		var datas=this.props.TestModel.get("list");
		for(var i=1;i<datas.length;i++){
			var record=datas[i];
			lists.push(<div style={{marginTop:"10px"}} key={record.findCode}>{record.airPortName}</div>);

			if(i%10==0){
				var lkey="floor-"+i;
				var item=(<LazyLoad key={lkey} height={300} offsetVertical={600}  offsetBottom={600}><div>{lists}</div></LazyLoad>);
				items.push(item);
				lists=[];
			}
		}
		 return items;
	},
	render:function () {
		
		var comp=(React.createElement("div",{className:"test"},this.initLayout()));
		 
		return comp;
	}
});

function mapStateToProps(state){
    var {TestModel} = state ; 
    return {TestModel};
} 
module.exports=connect(mapStateToProps)(TestView0);